package com.basker.pisces.domain.command.event;

import java.util.EventObject;

import com.basker.pisces.domain.command.CommandExecuteContext;
import com.basker.pisces.domain.command.run.CommandRunner;

/**
 * 命令执行的事件对象
 *
 * @author hangwen
 */
public class CommandExecuteEvent extends EventObject {

    private static final long serialVersionUID = 5172283395008182456L;

    private CommandExecuteContext context;
    private Object[] dataObjects;

    public CommandExecuteEvent(CommandRunner<?> runner, Object[] dataObjects) {
        super(runner);

        this.context = runner.getContext();
        this.dataObjects = dataObjects;
    }

    /**
     * 获取事件执行上下文
     *
     * @return
     */
    public CommandExecuteContext getContext() {
        return context;
    }

    /**
     * 获取执行的数据对象
     *
     * @return
     */
    public Object[] getDataObjects() {
        return dataObjects;
    }

    /**
     * 获取事件执行器
     */
    @Override
    public CommandRunner<?> getSource() {
        return (CommandRunner<?>) super.getSource();
    }

}
